package com.suirich.service.impl;

import java.io.UnsupportedEncodingException;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.suirich.bean.AboutUs;
import com.suirich.service.AboutUsService;
import com.suirich.service.BaseService;

@Service
@Transactional
public class AboutUsServiceImpl extends BaseService implements AboutUsService {

	public void create(AboutUs aboutUs) {
		this.aboutUsDao.create(aboutUs);
	}

    public AboutUs read(Long id) {
    	AboutUs aboutUs = this.aboutUsDao.read(id);
    	if(aboutUs != null){
            try {
                String contentInfo = "";
                byte[] b = (byte[])aboutUs.getContent();
                
                if(b != null){
                	contentInfo = new String(b,"UTF-8");
                }else{
                	contentInfo = "No content！";
                }
                aboutUs.setContentInfo(contentInfo);
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
    	}
        return aboutUs;
    }
    
    public void update(AboutUs HomeAd) {
        this.aboutUsDao.update(HomeAd);
    }

}
